package xiaZai;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class Download {
	public static void main(String[] args) throws IOException {
		URL url = new URL("http://cds-esd.sun.com/ESD6/JSCDL/sun_java_wireless_toolkit/2.5.2_01/sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh?AuthParam=1294638857_19a01caa096bb20e3d1a2108f9a37242&TicketId=co04L070TDA3PCPkOEMwg3qWMS8%3D&GroupName=CDS&FilePath=/ESD6/JSCDL/sun_java_wireless_toolkit/2.5.2_01/sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh&File=sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh");
		InputStream  is = url.openConnection().getInputStream();
		BufferedInputStream bis = new BufferedInputStream(is);
		
		File f = new File("/home/tarena/toolkit.sh");
		BufferedOutputStream bos= new BufferedOutputStream(new FileOutputStream(f));
		byte[] buf= new byte[1024];
		int num;
		while((num=bis.read(buf))!=-1){
			bos.write(buf, 0, num);
			bos.flush();
		}
		bos.close();bis.close();
	}
}
